From 49e59ee06bfaba9f47807750093fb54eaaa9cbda Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 18 Mar 2015 15:35:19 +0100 Subject: World:DoWithEntityByID() checks the entities-to-add as well. This allows plugins to create entities and immediately act on them using that call. This will most likely need to be added to most of the DoWith<> and ForEach<> calls. --- src/World.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/World.cpp b/src/World.cpp index f3837eb02..05eccb0fa 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2911,6 +2911,20 @@ bool cWorld::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_ bool cWorld::DoWithEntityByID(int a_UniqueID, cEntityCallback & a_Callback) { + // First check the entities-to-add: + { + cCSLock Lock(m_CSEntitiesToAdd); + for (auto & ent: m_EntitiesToAdd) + { + if (ent->GetUniqueID() == a_UniqueID) + { + a_Callback.Item(ent); + return true; + } + } // for ent - m_EntitiesToAdd[] + } + + // Then check the chunkmap: return m_ChunkMap->DoWithEntityByID(a_UniqueID, a_Callback); } -- cgit v1.2.3